package by.grsu.bso.beans;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import by.grsu.bso.model.ShoppingCartItem;
import by.grsu.bso.service.ServiceManager;
import by.grsu.bso.util.ValueHelper;

public class ShoppingCartItemUtilBean {

	public List<ShoppingCartItem> getCartItems(String parameter){
		
		int userId = ValueHelper.getIntParameter(parameter, -1);
		
		List<ShoppingCartItem> itemList = new ArrayList<ShoppingCartItem>();
		
		if(userId < 0) {
			//TODO: throw exception
			return itemList;
		}
		
		try {
			itemList.addAll(ServiceManager.getShoppingCartItemService().findAllByUserId(userId));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return itemList;
	}
	
	

}
